using System;
using System.Data;
using System.Collections.Generic;
using ADOBase;
namespace eTMS.DAO{
	/********************************BEGIN SinhVienDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:26/10/2011 34:05:09</para>
	/// <para>Class Name: SinhVienDAO</para>
	/// <para>Description: Class access to table SinhVien in database. Coder should'nt code here.</para>
	///</summary>

	
	public partial class SinhVienDAO : DAOBase<SinhVienEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: SinhVien_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int SinhVien_ID){
			string strSQL="SELECT  [SinhVien_ID],[MaSinhVien],[TenSinhVien],[DiaChi],[Email],[SoCMND],[DienThoai],[GhiChu],[GioiTinh],[NgaySinh] FROM [SinhVien]  WHERE [SinhVien].[SinhVien_ID]=@SinhVien_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SinhVien_ID",SinhVien_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: SinhVien_ID</para>
		/// <para>Output: SinhVienEntity</para>
		///</summary>
		public SinhVienEntity SelectOne(int SinhVien_ID){
			IDbCommand cmd=this.CreateSelectOneCommand(SinhVien_ID);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: SelectOneByMaSinhVien</para>
		/// <para>Input: MaSinhVien</para>
		/// <para>Output: SinhVienEntity</para>
		///</summary>
		public SinhVienEntity SelectOneByMaSinhVien(string MaSinhVien){
			IDbCommand cmd=this.CreateSelectAllByKeyCommand("MaSinhVien",MaSinhVien);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [SinhVien_ID],[MaSinhVien],[TenSinhVien],[DiaChi],[Email],[SoCMND],[DienThoai],[GhiChu],[GioiTinh],[NgaySinh] FROM [SinhVien] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [SinhVien_ID],[MaSinhVien],[TenSinhVien],[DiaChi],[Email],[SoCMND],[DienThoai],[GhiChu],[GioiTinh],[NgaySinh] FROM [SinhVien]  WHERE [SinhVien].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of SinhVienEntity</para>
		///</summary>
		public List<SinhVienEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [SinhVien_ID],[MaSinhVien],[TenSinhVien],[DiaChi],[Email],[SoCMND],[DienThoai],[GhiChu],[GioiTinh],[NgaySinh] FROM [SinhVien]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [SinhVien_ID],[MaSinhVien],[TenSinhVien],[DiaChi],[Email],[SoCMND],[DienThoai],[GhiChu],[GioiTinh],[NgaySinh] FROM [SinhVien]  WHERE [SinhVien].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of SinhVienEntity</para>
		///</summary>
		public List<SinhVienEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: SinhVienEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(SinhVienEntity o){
			string strSQL="INSERT INTO [SinhVien]([MaSinhVien],[TenSinhVien],[DiaChi],[Email],[SoCMND],[DienThoai],[GhiChu],[GioiTinh],[NgaySinh]) VALUES  (@MaSinhVien,@TenSinhVien,@DiaChi,@Email,@SoCMND,@DienThoai,@GhiChu,@GioiTinh,@NgaySinh);SELECT  @@IDENTITY";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullMaSinhVien)
				this.CreateCommandParameter(cmd,"@MaSinhVien",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@MaSinhVien",o.MaSinhVien);

			if(o.IsNullTenSinhVien)
				this.CreateCommandParameter(cmd,"@TenSinhVien",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TenSinhVien",o.TenSinhVien);

			if(o.IsNullDiaChi)
				this.CreateCommandParameter(cmd,"@DiaChi",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiaChi",o.DiaChi);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullSoCMND)
				this.CreateCommandParameter(cmd,"@SoCMND",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SoCMND",o.SoCMND);

			if(o.IsNullDienThoai)
				this.CreateCommandParameter(cmd,"@DienThoai",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DienThoai",o.DienThoai);

			if(o.IsNullGhiChu)
				this.CreateCommandParameter(cmd,"@GhiChu",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GhiChu",o.GhiChu);

			if(o.IsNullGioiTinh)
				this.CreateCommandParameter(cmd,"@GioiTinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GioiTinh",o.GioiTinh);

			if(o.IsNullNgaySinh)
				this.CreateCommandParameter(cmd,"@NgaySinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgaySinh",o.NgaySinh);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: Save</para>
		/// <para>Input: SinhVienEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(SinhVienEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.SinhVien_ID=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of SinhVienEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<SinhVienEntity>list){
			foreach(SinhVienEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: SinhVienEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(SinhVienEntity o){
			string strSQL="UPDATE  [SinhVien] SET [SinhVien].[MaSinhVien]=@MaSinhVien,[SinhVien].[TenSinhVien]=@TenSinhVien,[SinhVien].[DiaChi]=@DiaChi,[SinhVien].[Email]=@Email,[SinhVien].[SoCMND]=@SoCMND,[SinhVien].[DienThoai]=@DienThoai,[SinhVien].[GhiChu]=@GhiChu,[SinhVien].[GioiTinh]=@GioiTinh,[SinhVien].[NgaySinh]=@NgaySinh WHERE [SinhVien].[SinhVien_ID]=@SinhVien_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSinhVien_ID)
				this.CreateCommandParameter(cmd,"@SinhVien_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SinhVien_ID",o.SinhVien_ID);

			if(o.IsNullMaSinhVien)
				this.CreateCommandParameter(cmd,"@MaSinhVien",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@MaSinhVien",o.MaSinhVien);

			if(o.IsNullTenSinhVien)
				this.CreateCommandParameter(cmd,"@TenSinhVien",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TenSinhVien",o.TenSinhVien);

			if(o.IsNullDiaChi)
				this.CreateCommandParameter(cmd,"@DiaChi",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiaChi",o.DiaChi);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullSoCMND)
				this.CreateCommandParameter(cmd,"@SoCMND",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SoCMND",o.SoCMND);

			if(o.IsNullDienThoai)
				this.CreateCommandParameter(cmd,"@DienThoai",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DienThoai",o.DienThoai);

			if(o.IsNullGhiChu)
				this.CreateCommandParameter(cmd,"@GhiChu",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GhiChu",o.GhiChu);

			if(o.IsNullGioiTinh)
				this.CreateCommandParameter(cmd,"@GioiTinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GioiTinh",o.GioiTinh);

			if(o.IsNullNgaySinh)
				this.CreateCommandParameter(cmd,"@NgaySinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgaySinh",o.NgaySinh);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,SinhVien_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int SinhVien_ID){
			string strSQL="UPDATE  [SinhVien] SET [SinhVien].["+ColumnName+"]=@ColumnName WHERE [SinhVien].[SinhVien_ID]=@SinhVien_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SinhVien_ID",SinhVien_ID);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: Update</para>
		/// <para>Input: SinhVienEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(SinhVienEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of SinhVienEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<SinhVienEntity>list){
			foreach(SinhVienEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateMaSinhVien</para>
		/// <para>Input: NewMaSinhVien,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateMaSinhVien(string NewMaSinhVien,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("MaSinhVien",NewMaSinhVien,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateTenSinhVien</para>
		/// <para>Input: NewTenSinhVien,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateTenSinhVien(string NewTenSinhVien,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("TenSinhVien",NewTenSinhVien,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateDiaChi</para>
		/// <para>Input: NewDiaChi,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateDiaChi(string NewDiaChi,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("DiaChi",NewDiaChi,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateEmail</para>
		/// <para>Input: NewEmail,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateEmail(string NewEmail,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Email",NewEmail,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateSoCMND</para>
		/// <para>Input: NewSoCMND,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateSoCMND(string NewSoCMND,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("SoCMND",NewSoCMND,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateDienThoai</para>
		/// <para>Input: NewDienThoai,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateDienThoai(string NewDienThoai,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("DienThoai",NewDienThoai,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateGhiChu</para>
		/// <para>Input: NewGhiChu,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGhiChu(string NewGhiChu,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("GhiChu",NewGhiChu,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateGioiTinh</para>
		/// <para>Input: NewGioiTinh,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGioiTinh(Byte NewGioiTinh,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("GioiTinh",NewGioiTinh,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: UpdateNgaySinh</para>
		/// <para>Input: NewNgaySinh,SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNgaySinh(string NewNgaySinh,int SinhVien_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NgaySinh",NewNgaySinh,SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [SinhVien]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: SinhVienEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(SinhVienEntity o){
			string strSQL="DELETE   FROM [SinhVien]   WHERE [SinhVien].[SinhVien_ID]=@SinhVien_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullSinhVien_ID)
				this.CreateCommandParameter(cmd,"@SinhVien_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SinhVien_ID",o.SinhVien_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: SinhVien_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int SinhVien_ID){
			string strSQL="DELETE   FROM [SinhVien]   WHERE [SinhVien].[SinhVien_ID]=@SinhVien_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@SinhVien_ID",SinhVien_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [SinhVien]   WHERE [SinhVien].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: Delete</para>
		/// <para>Input: SinhVienEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(SinhVienEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: SinhVien_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int SinhVien_ID){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(SinhVien_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select,delete by SinhVien_ID functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:26/10/2011 34:05:09</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: SinhVienEntity</para>
		///</summary>
		protected override SinhVienEntity MapObject(IDataReader r){
			SinhVienEntity entity = new SinhVienEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("SinhVien_ID");
						if (!r.IsDBNull(ordinal)) entity.SinhVien_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("MaSinhVien");
						if (!r.IsDBNull(ordinal)) entity.MaSinhVien = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("TenSinhVien");
						if (!r.IsDBNull(ordinal)) entity.TenSinhVien = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("DiaChi");
						if (!r.IsDBNull(ordinal)) entity.DiaChi = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Email");
						if (!r.IsDBNull(ordinal)) entity.Email = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("SoCMND");
						if (!r.IsDBNull(ordinal)) entity.SoCMND = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("DienThoai");
						if (!r.IsDBNull(ordinal)) entity.DienThoai = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("GhiChu");
						if (!r.IsDBNull(ordinal)) entity.GhiChu = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("GioiTinh");
						if (!r.IsDBNull(ordinal)) entity.GioiTinh = ((Byte)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NgaySinh");
						if (!r.IsDBNull(ordinal)) entity.NgaySinh = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END SinhVienDAOBase*****************************************/
	/*****************************************************************************************************/
}

